]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
st/scroll-view-fade: Don't assume fade area at (0,0)
authorFlorian Müllner <fmuellner@gnome.org>
Thu, 14 Jan 2021 15:58:20 +0000 (16:58 +0100)
committerFlorian Müllner <fmuellner@gnome.org>
Thu, 14 Jan 2021 16:28:01 +0000 (17:28 +0100)
The shader code currently only accounts for padding for the
bottom and right fades, but not for top and left.

As a result, we only fade the right edge when swiping through app
picker pages, whoops.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1569>

src/st/st-scroll-view-fade.glsl

index 9180aa18438ad96a4415dd0d4b4f3ae6163b6648..2eacfd9af541ff6a2f9350bfcfd0e531e069b12b 100644 (file)
@@ -44,16 +44,18 @@ void main ()
     if (x > fade_area_topleft[0] && x < fade_area_bottomright[0] &&
         y > fade_area_topleft[1] && y < fade_area_bottomright[1]) {
         float ratio = 1.0;
+        float fade_top_start = fade_area_topleft[1] + vfade_offset;
+        float fade_left_start = fade_area_topleft[0] + hfade_offset;
         float fade_bottom_start = fade_area_bottomright[1] - vfade_offset;
         float fade_right_start = fade_area_bottomright[0] - hfade_offset;
         bool fade_top = y < vfade_offset && fade_edges_top;
         bool fade_bottom = y > fade_bottom_start && fade_edges_bottom;
-        bool fade_left = x < hfade_offset && fade_edges_left;
+        bool fade_left = x < fade_left_start && fade_edges_left;
         bool fade_right = x > fade_right_start && fade_edges_right;
 
         float vfade_scale = height / vfade_offset;
         if (fade_top) {
-            ratio *= y / vfade_offset;
+            ratio *= (fade_area_topleft[1] - y) / (fade_area_topleft[1] - fade_bottom_start);
         }
 
         if (fade_bottom) {
@@ -62,7 +64,7 @@ void main ()
 
         float hfade_scale = width / hfade_offset;
         if (fade_left) {
-            ratio *= x / hfade_offset;
+            ratio *= (fade_area_topleft[0] - x) / (fade_area_topleft[0] - fade_left_start);
         }
 
         if (fade_right) {